<<<<<<< HEAD
<?php
header("Content-Type: text/html;charset=utf-8");
include_once './includes/auth.php';
include_once './includes/res.php';
include_once './includes/header.php';

$id = $_GET['id'];

require_once 'service/GoalService.php';
$goalService = new GoalService();
$goal = $goalService->getGoal($id);
?>
<link rel='stylesheet' type='text/css' href="assets/js/fullcalendar/fullcalendar.css"/>
<link rel='stylesheet' type='text/css' href='assets/js/fullcalendar/fullcalendar.print.css' media='print' /> 
<script type='text/javascript' src='assets/js/fullcalendar/fullcalendar.min.js'></script>
<div class="container">
    <section>
        <div class="row">
            <div class="span6">
                <div class="well">
                    <div><h2 class="strong" style="text-align:center"><?php echo $goal['name'];?></h2></div>
                    <div>
                        <table class="table table-striped">
                            <tr><th>类型</th><td>习惯养成</td></tr>
                            <tr><th>状态</th><td><?php echo $goal['status'];?></td></tr>
                            <tr><th>开始时间</th><td><?php echo substr($goal['started_on'], 0, 10);?></td></tr>
                            <tr><th>结束时间</th><td><?php echo substr($goal['ended_on'], 0, 10);?></td></tr>
                            <tr>
                                <th>进度</th> 
                                <td>
                                    <?php
                                    $day = date('Y-m-d');
                                    $started_on = strtotime(substr($goal['started_on'], 0, 10));
                                    $today = strtotime($day);
                                    $daycount = round(($today - $started_on) / 3600 / 24) + 1;
                                    $percent = $daycount * 100 / 21;
                                    ?>
                                    <div class="progress progress-success">
                                        <div class="bar" style="width: <?php echo $percent.'%';?>;" title="<?php echo $percent.'%';?>"></div>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
            <div class="span6" style="margin-top: -40px;">
                <div id='calendar'></div>
            </div>
        </div>
    </section>
</div>
<script type="text/javascript">
$(function() {
	var url = "modules/goal/goal-activities.php?id=<?php echo $id?>";
	$.getJSON(url, function(data) {
		var events = new Array();
		for (var i = 0; i < data.length; i++) {
		    var event = {
		    	id: data[i].id,
		    	title: data[i].status,
		    	start: data[i].day,
	            // color: "#0074cc",
	            className: "ok",
	            // backgroundColor:'red'
		    };
		    events.push(event);
		}
		$('#calendar').fullCalendar({
	        monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
	        dayNamesShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
	        today: ["今天"],
	        buttonText: {
	        	today: "今天",
	        	prev: "上一月",
	        	next: "下一月",
	        	month: "月",
	        	agendaWeek: "周",
	        	agendaDay: "天"
	        },
	        events: events
	    });
		$('#calendar').fullCalendar("select", new Date("<?php echo $goal['started_on'];?>"), new Date("<?php echo $goal['ended_on'];?>"), false);
	});
});
</script>
<?php 
include_once './includes/footer.php';
=======
<?php
header("Content-Type: text/html;charset=utf-8");
include_once './includes/auth.php';
include_once './includes/res.php';
include_once './includes/header.php';

$id = $_GET['id'];

require_once 'service/GoalService.php';
$goalService = new GoalService();
$goal = $goalService->getGoal($id);
?>
<link rel='stylesheet' type='text/css' href="assets/js/fullcalendar/fullcalendar.css"/>
<link rel='stylesheet' type='text/css' href='assets/js/fullcalendar/fullcalendar.print.css' media='print' /> 
<script type='text/javascript' src='assets/js/fullcalendar/fullcalendar.min.js'></script>
<div class="container">
    <section>
        <div class="row">
            <div class="span6">
                <div class="well">
                    <div><h2 class="strong" style="text-align:center"><?php echo $goal['name'];?></h2></div>
                    <div>
                        <table class="table table-striped">
                            <tr><th>类型</th><td>习惯养成</td></tr>
                            <tr><th>状态</th><td><?php echo $goal['status'];?></td></tr>
                            <tr><th>开始时间</th><td><?php echo substr($goal['started_on'], 0, 10);?></td></tr>
                            <tr><th>结束时间</th><td><?php echo substr($goal['ended_on'], 0, 10);?></td></tr>
                            <tr>
                                <th>进度</th> 
                                <td>
                                    <?php
                                    $day = date('Y-m-d');
                                    $started_on = strtotime(substr($goal['started_on'], 0, 10));
                                    $today = strtotime($day);
                                    $daycount = round(($today - $started_on) / 3600 / 24) + 1;
                                    $percent = $daycount * 100 / 21;
                                    ?>
                                    <div class="progress progress-success">
                                        <div class="bar" style="width: <?php echo $percent.'%';?>;" title="<?php echo $percent.'%';?>"></div>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
            <div class="span6" style="margin-top: -40px;">
                <div id='calendar'></div>
            </div>
        </div>
    </section>
</div>
<script type="text/javascript">
$(function() {
	var url = "modules/goal/goal-activities.php?id=<?php echo $id?>";
	$.getJSON(url, function(data) {
		var events = new Array();
		for (var i = 0; i < data.length; i++) {
		    var event = {
		    	id: data[i].id,
		    	title: data[i].status,
		    	start: data[i].day,
	            // color: "#0074cc",
	            className: "ok",
	            // backgroundColor:'red'
		    };
		    events.push(event);
		}
		$('#calendar').fullCalendar({
	        monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
	        dayNamesShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
	        today: ["今天"],
	        buttonText: {
	        	today: "今天",
	        	prev: "上一月",
	        	next: "下一月",
	        	month: "月",
	        	agendaWeek: "周",
	        	agendaDay: "天"
	        },
	        events: events
	    });
		$('#calendar').fullCalendar("select", new Date("<?php echo $goal['started_on'];?>"), new Date("<?php echo $goal['ended_on'];?>"), false);
	});
});
</script>
<?php 
include_once './includes/footer.php';
>>>>>>> 20d6c557d209a3f376420616f57b4bd953611975
?>